                                                        
<div id="profile_view">

    <section class='hbox stretch'>

        <aside class='aside' style='width: 100%'>
            <div role="tabpanel" class='p-l'>

                <!-- Nav tabs -->
                <ul class="nav nav-pills nav-stacked col-md-3 text-sm" role="tablist">
                    <li role="presentation" class="active">
                        <a href="#basic" aria-controls="basic" role="tab" data-toggle="pill">
                            Overview
                            <i class="fa fa-chevron-right pull-right p-t-xs"></i>
                        </a>
                    </li>
                    <li role="presentation">
                        <a href="#groups" aria-controls="groups" role="tab" data-toggle="pill">
                            Groups & Dates
                            <i class="fa fa-chevron-right pull-right p-t-xs"></i>
                        </a>
                    </li>

                    <?php if (isset($category['settings']['family_info']) && $category['settings']['family_info'] == "1") { ?>
                        <li role="presentation">
                            <a href="#family" aria-controls="family" role="tab" data-toggle="pill">
                                Family
                                <i class="fa fa-chevron-right pull-right p-t-xs"></i>
                            </a>
                        </li>
                    <?php } ?>

                    <li role="presentation">
                        <a href="#notes" aria-controls="notes" role="tab" data-toggle="pill">
                            Notes
                            <i class="fa fa-chevron-right pull-right p-t-xs"></i>
                        </a>
                    </li>
                </ul>

                <!-- Tab panes -->
                <div class="tab-content col-md-9">
                    <div role="tabpanel" class="tab-pane active" id="basic">
                        <div class='row'>
                            <div class='col-lg-8'>
                                <table class="table table-condensed details_table">
                                    <!--<tr>
                                        <th>Name:</th>
                                        <td style='text-transform: capitalize;'>
                                    <?php
                                    echo $member['Member']['last_name'] . ' ' . $member['Member']['first_name'];

                                    if ($member['Member']['title'] != '') {
                                        echo " ({$member['Member']['title']})";
                                    }
                                    ?>
                                        </td>
                                    </tr>-->

                                    <tr>
                                        <th width='50%'>Birth Date:</th>
                                        <td><?php echo $member['Member']['dob'] ? date('d F Y', strtotime($member['Member']['dob'])) : ""; ?></td>
                                    </tr>
                                    <!--<tr>
                                        <th>Gender:</th>
                                        <td><?php echo $member['Member']['gender']; ?></td>
                                    </tr>-->
                                    <tr>
                                        <th>Marital Status:</th>
                                        <td style='text-transform: capitalize;'><?php echo $member['Member']['marital_status']; ?></td>
                                    </tr>
                                    <tr>
                                        <th>Place of Birth:</th>
                                        <td><?php echo $member['Member']['place_of_birth']; ?></td>
                                    </tr>

                                    <tr>
                                        <th>Hometown:</th>
                                        <td><?php echo $member['Member']['home_town']; ?></td>
                                    </tr>

                                    <tr>
                                        <th>Nationality:</th>
                                        <td><?php echo $member['Member']['nationality']; ?></td>
                                    </tr>

                                    <tr>
                                        <th>Educational Background:</th>
                                        <td><?php echo $member['Member']['educational_bg']; ?></td>
                                    </tr>

                                    <tr>
                                        <th>Field of study:</th>
                                        <td><?php echo $member['Member']['field_of_study']; ?></td>
                                    </tr>

                                    <tr>
                                        <th>Tribe: </th>
                                        <td><?php echo $member['Member']['tribe']; ?></td>

                                    </tr>
                                    <tr>
                                        <th>Profession: </th>
                                        <td><?php echo $member['Member']['profession']; ?></td>
                                    </tr>
                                    <tr>
                                        <th>Occupation:</th>
                                        <td><?php echo $member['Member']['occupation']; ?></td>

                                    </tr>
                                    <tr>
                                        <th>Position: </th>
                                        <td><?php echo $member['Member']['position']; ?></td>
                                    </tr>
                                </table>
                            </div>

                            <div class='col-lg-4'>
                                <?php
                                $src = null;

                                if (isset($member['OrganisationMemberImage']['MemberImage']['url'])) {
                                    $src = $this->Html->url($member['OrganisationMemberImage']['MemberImage']['url']);
                                }
                                ?>

                                <div id="image-box" class="image-box" style="width: 120px; height: 150px; border: solid 1px #ddd; margin: 0px auto; background-position: center;
                                     background-size: cover; <?php echo isset($src) ? "background-image: url('$src');" : ''; ?>">
                                </div>

                                <div style="margin-top: 10px; text-align: center;">
                                    <span class="btn btn-sm btn-default fileinput-button single-file-upload-manager"
                                          data-url='<?php echo $this->Html->url(array('controller' => 'Images', 'action' => 'upload_image_and_tag')); ?>'
                                          data-save_to='img/org_<?php echo $org_id; ?>'
                                          data-max-filesize='2000000'
                                          data-filetypes='/(\.|\/)(gif|jpe?g|png)$/i'
                                          data-image_max_width = '300'
                                          data-image_max_height='300'
                                          data-number_upload_files= 1
                                          data-extra_params_callback='member_view.image_upload_extra_param_callback'
                                          data-callback='member_view.image_upload_callback'
                                          >
                                        <i class="fa fa-upload"></i>
                                        <span>Change</span>
                                        <input id="fileupload" type="file" name="files[]" multiple="">
                                    </span>
                                    <div id="single-upload-progress" class="progress hide" style="height: 7px; margin: 10px 0px;">
                                        <div class="progress-bar progress-bar-success"></div>
                                    </div>

                                </div>
                            </div>

                            <div class='col-lg-12'>
                                <table class="table table-condensed details_table">
                                    <?php if ($member['Member']['MemberPhoneNumber']) { ?>
                                        <tr>
                                            <th width="30%" class="text-left" nowrap style='vertical-align:top;'>
                                                <i class="fa fa-mobile-phone text-info"></i>
                                                Phone Numbers
                                            </th>
                                            <td width="70%">
                                                <?php
                                                foreach ($member['Member']['MemberPhoneNumber'] as $number) {
                                                    $icon = '';
                                                    switch ($number['type']) {
                                                        case 'mobile': $icon = 'fa-mobile-phone';
                                                            break;
                                                        case 'office': $icon = 'fa-phone';
                                                            break;
                                                        case 'home': $icon = 'fa-home';
                                                            break;
                                                        default: $icon = 'fa-phone';
                                                            break;
                                                    }
                                                    echo "<div class='row m-b-xs' title='" . ucfirst($number['type']) . ' Phone' . "'>";
                                                    echo "<div class='col-lg-1 text-center'><i class='fa $icon' style='width: 10px; text-center;'></i></div>";
                                                    echo "<div class='col-lg-6'><a href='#' class='text-info send_sms_btn' data-number='{$number['number']}' title='Send SMS Message'>" . $number['number'] . "</a></div>";
                                                    //echo "<div class='col-lg-2'><i class='fa fa-envelope'></i></a></div>";
                                                    echo "</div>";
                                                }
                                                ?>
                                            </td>
                                        </tr>
                                    <?php } ?>

                                    <?php if ($member['Member']['MemberEmail']) { ?>
                                        <tr> 
                                            <th width="30%" class="text-left" style='vertical-align: top;'>
                                                <i class="fa fa-envelope text-info"></i>
                                                Email Addresses:
                                            </th>
                                            <td>
                                                <?php foreach ($member['Member']['MemberEmail'] as $email) { ?>
                                                    <span class='fa-ho block m-b-xs'>
                                                        <a class="text-info" href="mailto:<?php echo $email['email']; ?>" target="_blank">
                                                            <?php echo $email['email']; ?>
                                                        </a>
                                                    </span>
                                                <?php } ?>
                                            </td>
                                        </tr>
                                    <?php } ?>

                                    <tr>
                                        <th width="30%" class="text-left">
                                            <i class="fa fa-home text-info"></i>
                                            Address & Location
                                        </th>
                                        <td>
                                            <?php if ($member['Member']['address'] != '') { ?>
                                                <div class="m-b-xs">
                                                    <?php echo $member['Member']['address']; ?>
                                                </div>
                                            <?php } ?>

                                            <div class="m-b-xs">
                                                <?php echo $member['Member']['residential_address']; ?> 
                                                <?php echo $member['Member']['residential_region']; ?> <?php echo $member['Member']['residential_city']; ?>
                                                <?php echo $member['Member']['residential_zip_code']; ?>
                                            </div>
                                        </td>
                                    </tr>

                                    <tr>
                                        <th width="30%" class="text-left">
                                            <i class="fa fa-briefcase text-info"></i>
                                            Work Place
                                        </th>
                                        <td class="top" style="vertical-align: top;">
                                            <?php if ($member['Member']['business_name']) { ?>
                                                <div class="m-b-xs font-bold"><?php echo $member['Member']['business_name']; ?></div>
                                            <?php } ?>

                                            <div>
                                                <?php echo $member['Member']['business_address']; ?> 
                                                <?php echo $member['Member']['business_city']; ?> <?php echo $member['Member']['business_region']; ?>
                                                <?php echo $member['Member']['business_zip_code']; ?>
                                            </div>
                                        </td>
                                    </tr>

                                    <?php if ($member['Member']['website'] != '') { ?>
                                        <tr>
                                            <th width="30%" class="text-left">
                                                <i class="fa fa-globe text-info"></i>
                                                Website:
                                            </th>
                                            <td>
                                                <a class="text-info" href="<?php echo $member['Member']['website']; ?>" target="_blank">
                                                    <?php echo $member['Member']['website']; ?>
                                                </a>
                                            </td>
                                        </tr>
                                    <?php } ?>
                                </table>
                            </div>
                        </div>
                    </div>

                    <div role="tabpanel" class="tab-pane" id="groups">
                        <div class="col-lg-6">
                            <header>
                                <h5 class="pull-left">Groups And Associations</h5>

                <!--<a href="#" class="pull-right edit-btn btn btn-mini"><i class="icon icon-pencil"></i> Edit</a>-->
                            </header>

                            <table class="table table-condensed details_table">
                                <?php
                                if ($member['OrganisationMemberGroup']) {
                                    foreach ($org_info['OrganisationGroupType'] as $group) {
                                        ?>
                                        <tr>
                                            <th width='50%'><?php echo $group['name']; ?>:</th>
                                            <td>
                                                <?php
                                                $name = 'N/A';
                                                foreach ($member['OrganisationMemberGroup'] as $mg) {
                                                    if ($mg['OrganisationGroup'] && $mg['OrganisationGroup']['organisation_group_type_id'] == $group['id']) {
                                                        $name = $mg['OrganisationGroup']['name'];
                                                        break;
                                                    }
                                                }

                                                echo $name;
                                                ?>
                                            </td>
                                        </tr>
                                        <?php
                                    }
                                } else {
                                    ?>

                                    <tr>
                                        <th>Member Is Not Associated With Any Groups</th>
                                    </tr>
                                <?php } ?>
                            </table>
                        </div>

                        <div class="col-lg-6">
                            <header>
                                <h5 class="pull-left">Important Dates</h5>

                <!--<a href="#" class="pull-right edit-btn btn btn-mini"><i class="icon icon-pencil"></i> Edit</a>-->
                            </header>

                            <table class="table table-condensed details_table">

                                <?php
                                if ($member['OrganisationMemberAnniversary']) {
                                    foreach ($org_info['OrganisationAnniversary'] as $date) {
                                        ?>
                                        <tr>
                                            <th width='40%'><?php echo $date['name']; ?>:</th>
                                            <td>
                                                <?php
                                                $date_value = "N/A";
                                                foreach ($member['OrganisationMemberAnniversary'] as $md) {
                                                    if ($md['organisation_anniversary_id'] == $date['id'] && $md['value'] != '') {
                                                        $date_value = date('jS M, Y', strtotime($md['value']));
                                                        break;
                                                    }
                                                }

                                                echo $date_value;
                                                ?>
                                            </td>
                                        </tr>
                                        <?php
                                    }
                                } else {
                                    ?>

                                    <tr>
                                        <th>Member Has No Important Dates Recorded</th>
                                    </tr>
                                <?php } ?>
                            </table>
                        </div>
                    </div>

                    <?php if (isset($category['settings']['family_info']) && $category['settings']['family_info'] == "1") { ?>
                        <div role="tabpanel" class="tab-pane" id="family">


                            <header>
                                <h5 class="pull-left">Family</h5>

                                                                                <!--<a href="#" class="pull-right edit-btn btn btn-mini"><i class="icon icon-pencil"></i> Edit</a>-->
                            </header>

                            <table class="table table-condensed details_table">
                                <tr>
                                    <td width="25%">Father:</td>
                                    <td>
                                        <?php echo isset($member['Member']['MemberParent'][0]) ? $member['Member']['MemberParent'][0]['name'] : 'N/A'; ?>
                                    </td>
                                </tr>

                                <tr>
                                    <td width="25%">Mother:</td>
                                    <td>
                                        <?php echo isset($member['Member']['MemberParent'][1]) ? $member['Member']['MemberParent'][1]['name'] : 'N/A'; ?>
                                    </td>
                                </tr>
                                <tr>
                                    <td width="25%">Spouse:</td>
                                    <td>
                                        <?php echo isset($member['Member']['MemberSpouse'][0]) ? $member['Member']['MemberSpouse'][0]['name'] : 'N/A'; ?>
                                    </td>
                                </tr>

                                <?php
                                $positions = array('1st', '2nd', '3rd', '4th', '5th', '6th', '7th', '8th', '9th', '10th');
                                foreach ($member['Member']['MemberChild'] as $i => $child) {
                                    ?>
                                    <tr>
                                        <?php if ($i == 0) { ?>
                                            <td>Children:</td>
                                        <?php } else { ?>
                                            <td>&nbsp;</td>
                                        <?php } ?>
                                        <td>
                                            <?php echo $child['name']; ?>
                                        </td>
                                    </tr>
                                <?php } ?>
                            </table>
                        </div>
                    <?php } ?>

                    <div role="tabpanel" class="tab-pane" id="notes">
                        <?php 
                        if( $member['OrganisationMemberNote']['note'] ) { ?>
                            <div class="p-b-sm m-b-sm">
                                <?php echo $member['OrganisationMemberNote']['note']; ?>
                            </div>
                            <?php
                        } else { ?>
                            <div class="p-b-sm m-b-sm text-muted">
                                No notes recorded for this member 
                            </div>
                        <?php
                        }
                        ?>
                    </div>
                </div>

            </div>
        </aside>
    </section>



</div>


